<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>情感分析台</title>
    <!-- 引入 Google Fonts 中的现代字体 -->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
    <!-- 引入 ACE CDN -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
    <!-- 引入 jquery CDN -->
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>

    <style>
        /* 通用样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html,
        body {
            width: 100%;
            height: 100%;
            font-family: 'Poppins', sans-serif;
            background: linear-gradient(135deg, #e0f7fa, #f4f4f9);
        }

        /* 导航栏样式 */
        .container .navbar {
            width: 100%;
            height: 80px;
            background: linear-gradient(45deg, #0084ff, #00c3ff);
            display: flex;
            align-items: center;
            padding: 0 40px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            transition: background 0.3s ease;
            position: relative;
            z-index: 10;
            gap: 25px;
        }

        .container .navbar a {
            display: inline-block;
            width: auto;
            padding: 12px 20px;
            color: white;
            font-size: 18px;
            font-weight: 500;
            text-decoration: none;
            text-align: center;
            transition: all 0.3s ease;
            border-radius: 8px;
            position: relative;
        }

        .container .navbar a:hover {
            background-color: #9acd32;
            transform: translateY(-2px);
        }

        /* 当前激活页面的导航栏链接样式 */
        .container .navbar a.active {
            box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
            background-color: rgba(255, 255, 255, 0.1);
        }

        /* 上部文本输入框样式 */
        .container .part1 {
            width: 90%;
            max-width: 1200px;
            margin: 20px auto;
            height: auto;
            animation: fadeIn 0.8s ease;
        }

        .container .part1 .text {
            width: 100%;
            height: 400px; /* 增加高度 */
            padding: 20px; /* 增加内边距 */
            font-size: 18px; /* 增大字体大小 */
            border: 1px solid #ccc;
            border-radius: 10px;
            resize: none;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
            background-color: rgba(255, 255, 255, 0.8);
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }

        .container .part1 .text:focus {
            outline: none;
            border-color: #00c3ff;
            box-shadow: 0 0 10px rgba(0, 195, 255, 0.3);
        }

        /* 提交按钮和结果显示区域样式 */
        .container .part2 {
            width: 90%;
            max-width: 1200px;
            margin: 20px auto;
            height: auto;
            animation: fadeIn 0.8s ease;
        }

        .container .part2 .btn-submit {
            width: 120px;
            height: 50px;
            font-size: 16px;
            float: right;
            background-color: #26bb9c;
            color: white;
            border-radius: 10px;
            border: none;
            cursor: pointer;
            background: linear-gradient(45deg, #26bb9c, #1e967d);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        .container .part2 .btn-submit:hover {
            background-color: #1e967d;
            transform: translateY(-3px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .container .part2 .result {
            width: 100%;
            height: auto;
            min-height: 200px;
            background-color: white;
            border: 1px solid #ccc;
            border-radius: 10px;
            padding: 15px;
            margin-top: 70px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        }

        .container .part2 .result:hover {
            border-color: #00c3ff;
            box-shadow: 0 0 10px rgba(0, 195, 255, 0.3);
        }

        .container .part2 .result pre {
            font-size: 16px;
            white-space: pre-wrap;
        }

        /* 淡入动画关键帧 */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 导航栏 -->
        <div class="navbar">
            <a href="/MainPagehtml/MainPage.html" class="navbar-left">首页</a>
            <a href="/analysis">情感分析</a>
            <a href="/MainPagehtml/CorpusImport.html">语料导入</a>
            <a href="/MainPagehtml/CorpusModify.html">语料修改</a>
            <a href="/MainPagehtml/CorpusQuery.html">语料查询</a>
            <a href="/MainPagehtml/userModelCorpus.html">模型语料</a>
     <!--       <a href="/MainPagehtml/ModelShow.html">模型效果</a>-->
        </div>
        <!-- 上部呈现，文本输入框 -->
        <div class="part1">
            <textarea class="text" id="inputText" placeholder="请输入言语内容"></textarea>
        </div>
        <!-- 提交并且得到结果，并显示 -->
        <div class="part2">
            <button class="btn-submit" onclick="submit()">情感分析</button>
            <div class="result" id="outputText"></div>
        </div>
    </div>

    <script>
        const input = document.getElementById('inputText');
        const output = document.getElementById('outputText');

        function submit() {
            const inputValue = input.value;
            $.ajax({
                method: 'Post',
                url: '/language',
                dataType: 'json',
                contentType: 'application/json;charset=utf-8',
                data: JSON.stringify({
                    'input': inputValue
                }),
                success: function (data) {
                    show_result(data);
                }
            });
            function show_result(data) {
                var result = $(".container .part2 .result");
                result.empty();
                var emotion = data.status;
                output.textContent = `该蒙古语言语情感为：${emotion}`;
            }
        }

        const currentUrl = window.location.href;
        const navLinks = document.querySelectorAll('.navbar a');
        navLinks.forEach(link => {
            if (currentUrl.includes(link.getAttribute('href'))) {
                link.classList.add('active');
            }
        });
    </script>
</body>

</html>

